package org.example.c2;

import org.openjdk.jcstress.annotations.*;
import org.openjdk.jcstress.infra.results.II_Result;


/**
 * @author liu-rui
 * @date 2020/6/3 下午3:18
 * @description
 * 意外的结果,怎么会有r1=１，r2=２的情况？
 *
 * 需要通过以下方式来运行
 * mvn clean package
 * java -jar target/jcstresss.jar
 *
 * @since
 */

@JCStressTest
@Outcome(id = {"0, 0", "0, 2", "1, 0"}, expect = Expect.ACCEPTABLE, desc = "Normal outcome")
@Outcome(id = {"1, 2"}, expect = Expect.ACCEPTABLE_INTERESTING, desc = "Abnormal outcome")
@State
public class Demo2 {
    int a = 0;
    int b = 0;

    @Actor
    public void method1(II_Result r) {
        r.r2 = a;
        b = 1;
    }

    @Actor
    public void method2(II_Result r) {
        r.r1 = b;
        a = 2;
    }
}